
#include <BScript>
#include "ClassObject.h"

ClassObject::ClassObject() : BClass("Object", true)
{
	insertMethod("Object()", &ClassObject::create);
	insertMethod("Object(Object&)", &ClassObject::create_object);

	insertMethod("void setName(string)", &ClassObject::setName);
	insertMethod("string name() const", &ClassObject::name);

	insertMethod("string className() const", &ClassObject::className);
	insertMethod("bool typed(string)", &ClassObject::typed);

	insertMethod("int typeCount() const", &ClassObject::typeCount);
	insertMethod("string typeName(int index) const", &ClassObject::typeName);

	insertMethod("bool setProperty(const string& name, const auto& value)", &ClassObject::setProperty);
	insertMethod("const auto& property(const string& name) const", &ClassObject::property);

	insertMethod("Object& = (Object&)", &ClassObject::assign_node);
}

void ClassObject::create(int argc, BValue* argv)
{

}
void ClassObject::create_object(int argc, BValue* argv)
{

}

void ClassObject::setName(int argc, BValue* argv)
{
	BObject* object = argv[0];
	const BString& name = argv[1];
	object->setName(name);
}
void ClassObject::name(int argc, BValue* argv)
{
	BObject* object = argv[0];
	argv[0] = object->name();
}

void ClassObject::className(int argc, BValue* argv)
{
	BObject* object = argv[0];
	argv[0] = new BString(object->className());
}
void ClassObject::typed(int argc, BValue* argv)
{
	const BString& type = argv[1];
	//BScript* script = self->script();
	//BClass* super = self;
	//while (super)
	//{
	//	if (super->name() == type)
	//	{
	//		argv[0] = true;
	//		break;
	//	}
	//	super = super->super();
	//}
}

void ClassObject::typeCount(int argc, BValue* argv)
{

}
void ClassObject::typeName(int argc, BValue* argv)
{

}

void ClassObject::setProperty(int argc, BValue* argv)
{
	BObject* object = argv[0];
	const BString& name = argv[1];
	const BValue& value = argv[2].refer();
	argv[0] = object->setProperty(name, value);
}
void ClassObject::property(int argc, BValue* argv)
{
	BObject* object = argv[0];
	const BString& name = argv[1];
	argv[0] = object->property(name);
}

void ClassObject::assign_node(int argc, BValue* argv)
{

}

